import request from '../utils/request';


/**
 *
 * @param url 地址
 * @param query 参数
 * @returns {never}
 */
export const fetchData = (url:any,query:any={}) => {
    return request({
        url: url,
        method: 'get',
        params:query

    });
};

/**
 *
 * @param url 地址
 *
 *
 */
export const fetchData1 = (url:any) => {
    return request({
        url: url,
        method: 'get',
    });
};

/**
 *
 * @param url 地址
 * @param query 参数
 * @returns {AxiosPromise}
 */
export const saveorUpadateDate = (url:any,query:any) => {
    return request({
        headers: {
            'Content-Type': 'application/json'
        },
        transformRequest: [function(data:any) {
            data = JSON.stringify(data)
            return data
        }],
        url: url,
        method: 'post',
         data:query
    });
};

export const saveorUpadateDateParam = (url:any,param:any) => {
    return request({
        headers: {
            'Content-Type': 'application/json'
        },
        transformRequest: [function(data:any) {
            data = JSON.stringify(data)
            return data
        }],
        url: url,
        method: 'post',
        params:param
    });
};

/**
 *
 * @param url 地址
 * @param query 参数
 * @returns {AxiosPromise}
 */
export const queryPostData = (url:any,query:any) => {
    return request({
        headers: {
            'Content-Type': 'application/json'
        },
        transformRequest: [function(data:any) {
            data = JSON.stringify(data)
            return data
        }],
        url: url,
        method: 'post',
        data:query
    });
};

/**
 *
 * @param url删除地址
 * @returns {AxiosPromise}
 */
export const  deteleData=(url:any) =>{
    return request({
        url: url,
        method: 'delete',
    })
}
/**
 *批量删除
 * @param url删除地址
 * @returns {AxiosPromise}
 */
export const  deteleAllData=(url:any,ids:any) =>{
    return request({
        url: url,
        method: 'delete',
        data: ids
    })
}

/**
 *删除数据通过实体类
 * @param url删除地址
 * @returns {AxiosPromise}
 */
export const  delData=(url:any,param:any) =>{
    return request({
        headers: {
            'Content-Type': 'application/json'
        },
        transformRequest: [function(data:any) {
            data = JSON.stringify(data)
            return data
        }],
        url: url,
        method: 'delete',
        data: param
    })
}

/**
 *删除数据通过实
 * @param url删除地址
 * @returns {AxiosPromise}
 */
export const  ExportData=(url:any,param:any={}) =>{
    return request({
        headers: {
            'Content-Type': 'application/json'
        },
        transformRequest: [function(data:any) {
            data = JSON.stringify(data)
            return data
        }],
        //响应返回的值的类型
        responseType: 'blob',
        url: url,
        method: 'post',
        data: param
    })
}

/**
 *上传表格数据
 * @param url删除地址
 * @returns {AxiosPromise}
 */
export const  UploadData=(url:any,param:any) =>{
    return request({
        headers: {
            'Content-Type': 'application/json'
        },
        transformRequest: [function(data:any) {
            data = JSON.stringify(data)
            return data
        }],
        //响应返回的值的类型
        responseType: 'blob',
        url: url,
        method: 'post',
        data: param
    })
}




